using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace The_Last_Knights.GUI
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class Label: Element2D
    {
        #region Attributes
        protected string _value;
        protected SpriteFont _fontInfo;
#endregion

        #region Properties
        public string Value
        {
            get { return _value; }
            set { _value = value; }
        }

        public SpriteFont FontInfo
        {
            get { return _fontInfo; }
            set { _fontInfo = value; }
        }
#endregion

        public Label(Game game, string text, string font, string ID, Vector2 pos, Vector2 size, Texture2D background)
            : base(game, ID, pos, size, background)
        {
            _value = text;
            _fontInfo = game.Content.Load<SpriteFont>(GameAssertPath.FONT_PATH + font);            
        } 

        public Vector2 GetBoundary()
        {
            return _fontInfo.MeasureString(_value);
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            SpriteBatch sb = GetSpriteBatch();
            if (sb != null)
            {
                sb.Begin();
                sb.DrawString(_fontInfo, _value, _position, Color.White);
                sb.End();
            }
            base.Draw(gameTime);
        }

        public void Draw(SpriteBatch sb, Vector2 position, Color color)
        {
            sb.Begin();
            sb.DrawString(_fontInfo, _value, position, color);
            sb.End();
        }    
    }
}
